<html>
克隆版
<table border="1" cellpadding="0" cellspacing="0">
	<tbody id="tbody1">
		<tr>
			<td>姓名</td>
			<td>密码</td>
			<td>操作</td>
		</tr>
		<tr>
			<td>a1</td>
			<td>a2</td>
			<td><input type="button" value="添加" onclick="cloneTr()"></td>
		</tr>
		<tr id="a1" style="display:none;">
			<td>a3</td>
			<td>a4</td>
			<td><input type="button" value="删除" onclick="moveTr(this)"></td>
		</tr>
	</tbody>
</table>
创建版
<table border="1" cellpadding="0" cellspacing="0">
	<tbody id="tbody2">
		<tr>
			<td>姓名</td>
			<td>密码</td>
			<td>操作</td>
		</tr>
		<tr>
			<td>a1</td>
			<td>a2</td>
			<td><input type="button" value="添加" onclick="createTr()"></td>
		</tr>
	</tbody>
</table>
插入版
<table id="tab3" border="1" cellpadding="0" cellspacing="0">
	<tr>
		<td>姓名</td>
		<td>密码</td>
		<td>操作</td>
	</tr>
	<tr>
		<td>a1</td>
		<td>a2</td>
		<td><input type="button" value="添加" onclick="insertTr();"></td>
	</tr>
</table>


<script type="text/javascript">
var cloneTr = function(){
	var tbody1 = document.getElementById("tbody1");
	var a1 = document.getElementById("a1");
	var newtr = a1.cloneNode(true);
	newtr.style.display = "";//不能使用newtr.style.display = "block"，不然tr会自动换行导致错位。
	tbody1.appendChild(newtr);
}
var moveTr = function(t){
	t.parentNode.parentNode.parentNode.removeChild(t.parentNode.parentNode);
}
var createTr = function(){
	var tbody2 = document.getElementById("tbody2");
	var newtr = document.createElement("tr");
	var newtd1 = document.createElement("td");
	var newtd2 = document.createElement("td");
	var newtd3 = document.createElement("td");
	newtd1.innerHTML="a3";
	newtd2.innerHTML="a4";
	newtd3.innerHTML="<input type='button' value='移除' onclick='moveTr(this)'/>";
	newtr.appendChild(newtd1);
	newtr.appendChild(newtd2);
	newtr.appendChild(newtd3);
	newtr.style.textAlign="center";
	tbody2.appendChild(newtr);
}
var insertTr = function(){
	var newtr=tab3.insertRow()
	newtr.style.textAlign="center";
	var td1=newtr.insertCell();
	var td2=newtr.insertCell();
	var td3=newtr.insertCell();
	td1.innerHTML="a3";
	td2.innerHTML="a4"
	td3.innerHTML="<input type='button' value='移除' onclick='moveTr(this);'/>";
}
</script>
</html>















